package setting

import (
	"errors"
	"gopkg.in/ini.v1"
)

var SmtpUser string
var SmtpPassword string
var SmtpHost string
var SmtpPort int

func initMailServer(config *ini.File) error {
	section := config.Section("email_server")
	SmtpUser = section.Key("smtp_user").MustString("")
	SmtpPassword = section.Key("smtp_password").MustString("")
	SmtpHost = section.Key("smtp_host").MustString("")
	SmtpPort = section.Key("smtp_host").MustInt(25)
	if SmtpHost == "" || SmtpUser == "" || SmtpPassword == "" {
		return errors.New("init email server failed, host, email and  password must be specified")
	}
	return nil
}
